package com.jielihaofeng.nio.c4;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;

/**
 * @author Johnnie Wind
 * @description 可写事件处理客户端
 * @date 2021/10/15 17:39
 */
public class WriteClient {

    public static void main(String[] args) throws IOException {

        SocketChannel sc = SocketChannel.open();
        sc.connect(new InetSocketAddress("localhost", 8080));

        int read = 0;

        while (true) {
            ByteBuffer buffer = ByteBuffer.allocate(1024 * 1024);
            read += sc.read(buffer);
            buffer.clear();
            System.out.println(read);
        }
    }

}
